<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="100px">
      <el-form-item label="商家名称" prop="shopName">
        <el-input
          v-model="queryParams.shopName"
          placeholder="请输入商家名称"
          clearable
          size="small"
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="服务商姓名" prop="serverName">
        <el-input
          v-model="queryParams.serverName"
          placeholder="请输入服务商姓名"
          clearable
          size="small"
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="企业名称" prop="corpName">
        <el-input
          v-model="queryParams.corpName"
          placeholder="请输入企业名称"
          clearable
          size="small"
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="商家法人姓名" prop="legalPersonName">
        <el-input
          v-model="queryParams.legalPersonName"
          placeholder="请输入商家法人姓名"
          clearable
          size="small"
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-tabs v-model="activeName" @tab-click="handleTabs">
      <el-tab-pane label="全部" name="1" />
      <el-tab-pane label="未审核" name="2" />
      <el-tab-pane label="审核通过" name="3" />
      <el-tab-pane label="已驳回" name="4" />
    </el-tabs>

    <el-table v-loading="loading" :data="list">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="店铺名称" show-overflow-tooltip align="center" prop="shop_name" />
      <el-table-column label="所属运营中心" align="center" prop="operation_name" />
      <el-table-column label="所属服务商" align="center" prop="real_name" />
      <el-table-column label="所属企业" show-overflow-tooltip align="center" prop="corp_name" />
      <el-table-column label="所属行业" align="center" prop="industry_name" />
      <el-table-column label="商家法人" align="center" prop="legal_person_name" />
      <el-table-column label="商家地址" show-overflow-tooltip align="center" prop="shop_address" />
      <el-table-column label="状态" align="center" prop="status" :formatter="formatShopStatus" />
      <el-table-column label="操作" align="center" prop="type">
        <template slot-scope="scope">
          <el-button
            size="small"
            type="text"
            icon="el-icon-view"
            @click="handleView(scope.row)"
            v-hasPermi="['union:shopExamine:info']">
            查看</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import { list } from '@/api/union/shopExamine'
import { formatShopStatus } from '@/utils/shop'

export default {
  name: 'shopExamine',
  data() {
    return {
      loading: false,
      list: [],
      showSearch: true,
      total: 0,
      activeName: "1",
      queryParams: {
        pageSize: 10,
        pageNum: 1,
        orderByColumn: "create_time",
        isAsc: "desc",
        shopName: null,
        serverName: null,
        corpName: null,
        legalPersonName: null,
      }
    }
  },
  created() {
    this.getList()
  },
  methods: {
    getList() {
      this.loading = true
      list(this.queryParams).then(response => {
        this.total = response.total
        this.list = response.rows
        this.loading = false
      })
    },
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList()
    },
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    handleTabs(tab) {
      this.queryParams.type = tab.name
      this.queryParams.pageNum = 1
      this.getList()
    },
    formatShopStatus(row) {
      return formatShopStatus(row.status)
    },
    handleView(row) {
      this.$router.push( "/union/shopExamine/info/" + row.shop_id )
    }
  }
}
</script>
